package models

import (
	"strconv"

	"github.com/astaxie/beego/orm"
)

//获取电影信息
func FilmDetails(FilmId string) (*Film, error) {
	o := orm.NewOrm()
	qs := o.QueryTable("film")
	film := new(Film)
	err := qs.Filter("id", FilmId).One(film)
	return film, err
}

//获取影院信息
func CinemaInfo(FilmId string) (*Seat, error) {
	Filmid, err := strconv.ParseInt(FilmId, 10, 64)
	o := orm.NewOrm()
	qs := o.QueryTable("seat")
	seat := new(Seat)
	err = qs.Filter("filmId", Filmid).One(seat)
	return seat, err
}

//获取订单
func OrderInfo(name string) ([]Order, int8) {
	o := orm.NewOrm()
	qs := o.QueryTable("order")
	userid, _ := Getuserid(name)
	order := make([]Order, 0)
	qs.Filter("userId", userid).All(&order)

	return order, 0
}
